import { InjectionKey } from 'vue'
import { createStore, Store, useStore as baseUseStore } from 'vuex'
import user from './modules/user'
import permission from './modules/permission'
import app from './modules/app'

export interface State {
  user: any
  permission: any
  app: any
}

export const key: InjectionKey<Store<State>> = Symbol()

const store = createStore<State>({
  modules: {
    app,
    user,
    permission
  }
})

export function useStore() {
  return baseUseStore(key)
}

export default store
